<template>
	<view>
		<map style="width: 750upx;height: 500upx;" :longitude="longitude" :latitude="latitude"></map>
		<order-info showOrderNum=true>
			<view v-if="status==1">
				<view class="title">上传交货内容</view>
				<van-uploader disabled image-fit="aspectFit" multiple=true max-count="3" :file-list="image"
								@after-read="afterRead('image',$event)" @delete="onDelete('image',$event)" preview-size="120upx" />
				<view class="title">货物上报</view>
				<textarea disabled class="context" :value="context"></textarea>
			</view>
		</order-info>
		<button class="button myButton" v-if="status==0" @click="showSubmit=true">我要交货</button>
		<button class="button" style="margin: 30upx auto;" v-else-if="status==1" @click="showAfterSale=true">我要售后</button>
		<button class="button myButton" v-else-if="status==2" @click="switchTab('/pages/index/index')">去接单</button>
		<button class="button" style="margin: 30upx auto;" v-if="status==1" @click="goTo('/pages/complaint/index')">我要投诉</button>
		<van-action-sheet :show="showSubmit" title="确认交货" @cancel="showSubmit=false" @click-overlay="showSubmit=false" @close="showSubmit=false" >
			<view style="padding: 32upx;">
				<view class="title">上传交货内容</view>
				<van-uploader image-fit="aspectFit" multiple=true max-count="3" :file-list="image"
								@after-read="afterRead('image',$event)" @delete="onDelete('image',$event)" preview-size="120upx" />
				<view class="title">货物上报</view>
				<textarea class="context" :value="context"></textarea>
			</view>
			<button class="button myButton" @click="redirectTo('/pages/finish/index')">确认交货</button>
		</van-action-sheet>
		<van-action-sheet :show="showAfterSale" title="售后" @cancel="showAfterSale=false" @click-overlay="showAfterSale=false" @close="showAfterSale=false" >
			<view style="padding: 32upx;">
				<van-radio-group :value="afterSale">
					<view class="flex-between">
						<label>是否购买保险</label>
						<view class="flex-align">
							<view  @click="afterSale='0'"  class="flex-align">
								<van-radio name="0"/>否
							</view>
							<view style="margin-left: 10upx;"  @click="afterSale='1'"  class="flex-align">
								<van-radio name="1"/>是
							</view>
						</view>
					</view>
				</van-radio-group>
				<view style="padding: 0;" v-if="afterSale=='1'">
					<van-field :value="afterSaleNum" @input="afterSaleNum=$event.detail" label="保险单" placeholder="请输入保险单"/>
				</view>
				<view v-else>
					<button style="margin: 50upx auto;" class="button" @click="goTo('/pages/feedback/index')">平台反馈</button>
				</view>
			</view>
		</van-action-sheet>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				status:0,
				longitude:0,
				latitude:0,
				showSubmit:false,
				image:[],
				context:'',
				showAfterSale:false,
				afterSale:'1',
				afterSaleNum:''
			}
		},
		onLoad(param){
			const that=this;
			that.status=param.status;
			uni.getLocation({
				type: 'gcj02',
				success: function (res) {
					that.longitude=res.longitude;
					that.latitude=res.latitude;
				}
			})
		}
	}
</script>

<style lang="scss" scoped>
	.myButton{
		margin: 100upx auto;
	}
	.title{
		margin-top: 40upx;
		font-size: 28upx;
		font-weight: bold;
		color: #333333;
	}
	.context{
		padding: 10upx;
		font-size: 24upx;
		font-weight: bold;
		color: #666666;
		opacity: 0.6;
		background: #F7F7F7;
		border-radius: 10upx;
	}
</style>
